public class EmailHander{
    public static String SendMail(String BodyString,String[] ToAddress,String subject,String displayName,List<Attachment> fileList)
    { 
            String mailStr;
            Messaging.Singleemailmessage mail=new Messaging.Singleemailmessage();
            mail.setToAddresses(ToAddress);
            mail.setSubject(subject);
            mail.setSenderDisplayName(displayName);
            mail.setHtmlBody(BodyString);
            mail.setPlainTextBody(BodyString);
            mail.setUseSignature(false);
            //Messaging.EmailFileAttachment[] fileAttachments = new Messaging.EmailFileAttachment[1];
            Messaging.Emailfileattachment att=new Messaging.Emailfileattachment();
           // List<Attachment> fileList=[select Body from Attachment where ParentId=:order.Id order by CreatedDate asc limit 1];
            if(fileList!=NULL && fileList.size()>0)
            {
                Attachment file=fileList.get(0);
                att.setBody(file.Body);
                att.setFileName('电子签名.bmp');
                //att..getContentType();
                Messaging.EmailFileAttachment[] fileAttachments = new Messaging.EmailFileAttachment[1];
                fileAttachments[0]=att;
                //fileAttachments[0].setContentType('ffff');
                mail.setFileAttachments(fileAttachments);
            }
           // mail.setFileAttachments(new Messaging.Emailfileattachment())
            try
            {
                Messaging.sendEmail(new Messaging.Singleemailmessage[]{mail});
                mailStr='用邮件方式发送订单到经销商成功';
            }
            catch(EmailException ex)
            {
                mailStr='用邮件方式发送订单到经销商失败'+ex.getMessage();
            }
        
        return mailStr;
    }
    
 }